package com.demo.config.webmvc;

import com.demo.commons.constant.ConStantsR;
import com.demo.config.custom.CustomConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>webmvc配置</p>
 *@author zwy
 *@date 2023/8/10 22:58
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private CustomConfig customConfig;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 在配置文件中已经配置过 可以不用在这儿配置了
        //registry.addResourceHandler("/**").addResourceLocations("classpath:/templates/");
        registry.addResourceHandler(ConStantsR.RESOURCE_UPLOAD + "/**").addResourceLocations("file:" + customConfig.getUploadPath());
        registry.addResourceHandler(ConStantsR.RESOURCE_DOWNLOAD + "/**").addResourceLocations("file:" + customConfig.getDownloadPath());
        


    }




}
